package com.hx.xiao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hx.xiao.entity.Users;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hx
 * @since 2024-03-21
 */
public interface UsersMapper extends BaseMapper<Users> {

    @Select("select * from users where phone=#{phone}")
    Users getByPhone(String phone);

    @Insert("insert into users(phone) values(#{phone})")
    int addByPhone(String phone);

    @Select("select * from users")
    List<Users> findAll();

    @Update("update users set username=#{username},phone=#{phone},komh=#{komh} where id=#{id}")
    int updateB(Users users);

    @Delete("delete from users where id=#{id}")
    int deleteB(Integer id);

    @Select("select id,username,phone,komh from users where id=#{id}")
    Users findB(Integer id);

    @Select("select * from users where username=#{username} and komh=#{komh} ")
    Users findBy(String username,String komh);

}
